package org.farng.mp3.id3;

import org.farng.mp3.InvalidTagException;
import org.farng.mp3.object.ObjectByteArraySizeTerminated;
import org.farng.mp3.object.ObjectNumberHashMap;
import org.farng.mp3.object.ObjectStringNullTerminated;

import java.io.IOException;


/**
 * Title: Description: Copyright:    Copyright (c) 2002 Company:
 *
 * @author Eric Farng
 * @version $Revision: 1.3 $
 */
public class FrameBodyGEOB extends AbstractID3v2FrameBody {
    /**
     * Creates a new FrameBodyGEOB object.
     */
    public FrameBodyGEOB() {
        //        this.setObject("TextEncoding", new Byte((byte) 0));
        //        this.setObject("MIME Type", "");
        //        this.setObject("Filename", "");
        //        this.setObject("Description", "");
        //        this.setObject("Encapsulated Object", new byte[0]);
    }

    public FrameBodyGEOB(FrameBodyGEOB body) {
        super(body);
    }

    /**
     * Creates a new FrameBodyGEOB object.
     *
     * @param textEncoding DOCUMENT ME!
     * @param mimeType DOCUMENT ME!
     * @param filename DOCUMENT ME!
     * @param description DOCUMENT ME!
     * @param object DOCUMENT ME!
     */
    public FrameBodyGEOB(byte textEncoding, String mimeType, String filename, String description, byte[] object) {
        this.setObject("TextEncoding", new Byte(textEncoding));
        this.setObject("MIME Type", mimeType);
        this.setObject("Filename", filename);
        this.setObject("Description", description);
        this.setObject("Encapsulated Object", object);
    }

    /**
     * Creates a new FrameBodyGEOB object.
     *
     * @param file DOCUMENT ME!
     *
     * @throws IOException DOCUMENT ME!
     * @throws InvalidTagException DOCUMENT ME!
     */
    public FrameBodyGEOB(java.io.RandomAccessFile file)
                  throws IOException, InvalidTagException {
        this.read(file);
    }

    /**
     * DOCUMENT ME!
     *
     * @param description DOCUMENT ME!
     */
    public void setDescription(String description) {
        setObject("Description", description);
    }

    /**
     * DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public String getDescription() {
        return (String) getObject("Description");
    }

    /**
     * DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public String getIdentifier() {
        return "GEOB" + ((char) 0) + getDescription();
    }

    /**
     * DOCUMENT ME!
     */
    protected void setupObjectList() {
        objectList.add(new ObjectNumberHashMap(ObjectNumberHashMap.TEXT_ENCODING, 1));
        objectList.add(new ObjectStringNullTerminated("MIME Type"));
        objectList.add(new ObjectStringNullTerminated("Filename"));
        objectList.add(new ObjectStringNullTerminated("Description"));
        objectList.add(new ObjectByteArraySizeTerminated("Encapsulated Object"));
    }
}